﻿@using XRM.Security.WebUI.MvcHelpers
@using MvcContrib.UI.Grid
@model XRM.Security.WebUI.Models.CertRegister.CertRegisterModel
@{
    Layout = null;
}


    @{
        var list = new List<XRM.Security.WebUI.Models.CertRegister.CertRegisterModel>();
        list.Add(Model);
        if (list.Any())
        {
            <hr />
            Html.Grid(list).Columns(column =>
                {
                    column.For(item => item.IdentityCenterName).Named("УЦ");
                    column.For(item => item.SerialNumber).Named("Серийный номер сертификата");
                    column.For(item => item.PCSerialNumber).Named("Серийный номер ПК");
                    column.For(item => item.ValidPeriod).Named("Срок действия");
                
                    column.Custom
                            (@<text>
                                    @if (!Convert.ToBoolean(ViewData["ReadOnly"]))
                                    {
                                      @Html.DialogFormButton(new DialogButtonOptions()
                                      {
                                        Text = "Редактировать",
                                        ContentUrl = Url.Action("CertDialog", "Request", new { id = item.Id }),
                                        Width = "800",
                                        Id = "dlgEditCertDialog",
                                        Image = "fa-pencil",
                                        OnSuccess = ViewData["BaseName"].ToString() + "RefreshRequestCert"
                                      })
                                    }
                                  <a href="@Url.Action("DownloadCert", new { id = item.Id })" title="Скачать"> <i class="fa fa-download fa-action"></i></a>
                                  @if (!Convert.ToBoolean(ViewData["ReadOnly"]))
                                  {
                                  <a href="javascript:void(0);" title="Удалить" onclick="DeleteRequestCert('@(ViewData["RequestWorkKindParamId"].ToString())', '@(ViewData["WorkKindIndex"].ToString())')"> <i class="fa fa-trash-o fa-action"></i></a>
                                  }
                              </text>).Named("").Attributes(nowrap => "nowrap");


                }).Attributes(@class => "table table-striped table-bordered", id => ViewData["BaseName"].ToString() + "table_id")
                .Empty("Нет данных для отображения")
                .Render();
        } 
    }

    <script type="text/javascript">
        function @(ViewData["BaseName"].ToString())RefreshRequestCert() {
            RefreshRequestParam('@(ViewData["WorkKindIndex"].ToString())');
        }
        $(document).ready(function () {
            @if (list.Any())
            {
                <text>
                $('#@(ViewData["BaseName"].ToString())table_id').dataTable({
                    paging: false,
                    bFilter: false,
                    bSort: false,
                    info: false
                });
                BindDialogButtons();
                </text>
            }
        });
    </script>
